package com.xjy.controller;

import com.xjy.model.auto.ProductionInfo;
import com.xjy.model.auto.UserInfo;
import com.xjy.service.IProductionInfoService;
import com.xjy.service.IProjectInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 作品信息表 前端控制器
 * </p>
 *
 * @author 达瓦里氏
 * @since 2021-11-13
 */
@RestController
@RequestMapping("/production-info")
@CrossOrigin
public class ProductionInfoController {

    @Autowired
    private IProductionInfoService productionInfoService;

    /*查询用户*/
    @GetMapping("/getProduction")
    public List<ProductionInfo> getProduction(){
        return productionInfoService.list();
    }

    /*通过id查询用户*/
    @GetMapping("/getProductionById/{id}")
    public ProductionInfo getProductionById(@PathVariable("id") int id){
        return productionInfoService.getById(id);
    }

    /*修改用户*/
    @PostMapping("/updateProduction")
    public void updateProduction(@RequestBody ProductionInfo productionInfo){
        productionInfoService.updateById(productionInfo);
    }

    /*添加用户*/
    @PostMapping("/setProduction")
    public void setUser(@RequestBody ProductionInfo productionInfo){
        productionInfoService.save(productionInfo);
    }

    /*删除用户*/
    @PostMapping("/deletedById/{id}")
    public boolean deleted(@PathVariable("id") int id){
        return productionInfoService.removeById(id);
    }
}
